




var _oMessages =
{
sNoSelectedMapping: LOCID_MAPLST_MUSTSELECT,
sConfirmAutomap: 	LOCID_MAPLST_CONFIRMAUTOMAP,
sAutoMapping:		LOCID_MAPLST_AUTOMAPING,
sCreatingMapping:	LOCID_MAPLST_CREATINGMAP
};






var _oConst =
{

entityMapId:					"entityMapId",


sCustomizationCommandObject:	"SystemCustomization",
sAutoMapCommand:				"AutoMapEntityMap",
sCreateMappingCommand:			"CreateAttributeMap",
sCommandParameterName:			"data",

sCreateMappingUrlFormat:		"createMapping.aspx?mappingId={0}",
iCreateDialogWidth:				820,
iCreateDialogHeight:			400,

sDeleteDialogUrlFormat:			"/_grid/cmds/dlg_delete.aspx?iObjType={0}&iTotal={1}",
sDeleteAction:					"delete",
iDeleteDialogWidth:				470,
iDeleteDialogHeight:			250
};







function MappingListJsWindowOnLoad()
{
gridMappings.OnBeforeFormLoad = onMappingDblClick;
gridMappings.SetParameter("disableDblClick", "0");
}

window.attachEvent('onload', MappingListJsWindowOnLoad);










function dispatchAction(aMappingList, sAction)
{

if (aMappingList.length <= 0)
{
alert(_oMessages.sNoSelectedMapping);
return;
}

switch (sAction)
{
case _oConst.sDeleteAction:
deleteMappingAction(aMappingList);
break;
}
}




function remoteMappingCommandCallback()
{
gridMappings.Refresh();
return true;
}




function createMappingAction()
{

var sUrl	= formatString(_oConst.sCreateMappingUrlFormat, _sEntityMapId);
var oResult	= openStdDlg(sUrl, null, _oConst.iCreateDialogWidth, _oConst.iCreateDialogHeight);


if (oResult != null)
{
var oCommand = new RemoteCommand(_oConst.sCustomizationCommandObject, _oConst.sCreateMappingCommand);
oCommand.SetParameter(_oConst.sCommandParameterName, oResult.sMappingXml);
executeRemoteCommand(oCommand, _oMessages.sCreatingMapping, remoteMappingCommandCallback);
}
}




function autoMapAction()
{

if (!confirm(_oMessages.sConfirmAutomap))
{
return;
}

var oCommand = new RemoteCommand(_oConst.sCustomizationCommandObject, _oConst.sAutoMapCommand);
oCommand.SetParameter(_oConst.entityMapId, _sEntityMapId);
executeRemoteCommand(oCommand, _oMessages.sAutoMapping, remoteMappingCommandCallback);
}




function deleteMappingAction(aMappingList)
{
var sUrl = prependOrgName(formatString(_oConst.sDeleteDialogUrlFormat, AttributeMap, aMappingList.length));

var oResult = openStdDlg(sUrl, aMappingList, _oConst.iDeleteDialogWidth, _oConst.iDeleteDialogHeight);

if (!IsNull(oResult))
{
gridMappings.Refresh();
}
}










function onMappingDblClick()
{
event.returnValue = false;
}
